var express = require('express');
var app = express();

var dbApi = require('./modules/db-api');

dbApi.open("127.0.0.1", 27017, 'apit');

var host = process.env.VCAP_APP_HOST || "0.0.0.0";
var port = process.env.VCAP_APP_PORT || "1371";
//load express configurations
var sessionStore = require('./lib/express_config').configure(app, express);
//load socketIO lib
var sioLib = require('./lib/socketioLib').configure(app, sessionStore, dbApi);

//load routes (after configurations)
require('./lib/routes')(app, sioLib, dbApi);

//start app server
app.listen(port, host); 